<?php

class User extends AppModel {
    
    public $name = "User";
    public $useTable = "admins";
    
    /**
     * check_login()
     * checks the username and password against the database
    */
    public function check_login($data) {
        $valid = false;
        
        $user = $this->find('first', array(
            "conditions" => array(
                "User.username" => $data["User"]["username"]
            )
        ));
        
        if (sizeof($user) > 0) {
            if ($user["User"]["password"] == md5($data["User"]["password"])) {
                $valid = $user;
            }
        }
        
        return $valid;
    }
}

?>